﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace TyNetCoreBlog.Models.Entities
{
    public class Category
    {

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [Required(ErrorMessage = "{0}不能为空")]
        [Display(Name = "分类名称")]
        public string Name { get; set; }

        [Required(ErrorMessage = "{0}不能为空")]
        [Display(Name = "分类排序")]
        [Range(1, 1000, ErrorMessage = "1-999")]
        public int Sort { get; set; }

        public virtual ICollection<Blog> Blogs { get; set; } = new List<Blog>();      //关联文章

    }
}
